#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

long long int digits[100] = { 0 };
int Compare(int a, int b)
{
	long long int ret1 = 0, ret2 = 0, out1,out2;
	double u = a, v = b;
	while (u >= 10) { u /= 10; ret1++; }
	while (v >= 10) { v /= 10; ret2++; }
	u = a; v = b;
	for (long int q = 0; q < ret2 + 1; q++)u *= 10; out1 = u + v;
	for (long int q = 0; q < ret1 + 1; q++)v *= 10; out2 = a + v;
	if (out1 > out2)return 1;
	else return 0;
}
void Bubble_sort(int digit, long long int* digits)
{
	int a = 0, b = 1;
	for (int i = 0; i < digit - 1; i++) {
		a = 0;
		b = 1;
		for (int j = 0; j < digit - 1 - i; j++) {
			if (Compare(digits[a], digits[b])) {
				digits[a] = digits[a] + digits[b];
				digits[b] = digits[a] - digits[b];
				digits[a] = digits[a] - digits[b];
			}
			a++;
			b++;
		}
	}
}

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)scanf("%lld", &digits[i]);
	if (n == 1) {
		printf("%lld", digits[0]);
		return 0;
	}
	Bubble_sort(n, digits);
	for (int j = n - 1; j >= 0; j--)printf("%lld", digits[j]);
	return 0;
}
/*float u=a, q=b;
	while (u >= 10)u /= 10;
	while (q >= 10)q /= 10;
	if (u > q)return 1;
	else return 0;
void Bubble_sort2(int digit, long long int* digits)
{
	int i = 0, j = 1,ret1,ret2,sub;
	for (float u, v; j < digit; j++, i++) {
		u = digits[i];
		v = digits[j];
		ret1 = 0, ret2 = 0;
		while (u >= 10) { u /= 10; ret1++; }
		while (v >= 10) { v /= 10; ret2++; }
		if ((int)u == (int)v) {
			if (ret1 > ret2) {
				for (int q = 0; q < ret1 - ret2; q++)v *= 10;
				sub = u - v;
				for(int r=i-1;)
			}

		}

	}
}*/

